package com.fxsen.commons.utils;
import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName SessionUtil
 * @Author fxsen
 * @Date 2021/7/20 10:10
 */
public class SessionUtils {
	/**
	 * 登录
	 * @param request
	 */
	public static void onLogin(Object object, HttpServletRequest request) {
		request.getSession().setAttribute(JwtUtils.JWT_HEADER_KEY, object);
	}

	/**
	 * 退出
	 * @param request
	 */
	public static void logOut(HttpServletRequest request) {
		request.getSession().removeAttribute(JwtUtils.JWT_HEADER_KEY);
		request.getSession().invalidate();
	}

	/**
	 * 获取当前用户
	 * @param request
	 * @return
	 */
	public static Object getUser(HttpServletRequest request) {
		return request.getSession().getAttribute(JwtUtils.JWT_HEADER_KEY);
	}
}
